Trò chơi đua xe động vật trong UNITY Engine
114.928 lượt xem;
- AnimationTestScript.cs
- Scripts /
- Example /
- Spriter2Unity /
- ThirdParty /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4 public class AnimationTestScript : MonoBehaviour
5 {
6 public enum TriggerType
7 {
8 Move,
9 Jump,
10 Hit,
11 Crouch
12 }
13
14 public float Speed;
15
16 private Animator anim;
17
18 public void SetTrigger(TriggerType type)
19 {
20 anim.SetTrigger(type.ToString());
21 }
22
23 private void Start()
24 {
25 anim = GetComponent<Animator>();
26 }
27
28 private void Update ()
29 {
30 anim.SetFloat("Speed", Speed);
31 }
32 }
2 using System.Collections;
3
4 public class AnimationTestScript : MonoBehaviour
5 {
6 public enum TriggerType
7 {
8 Move,
9 Jump,
10 Hit,
11 Crouch
12 }
13
14 public float Speed;
15
16 private Animator anim;
17
18 public void SetTrigger(TriggerType type)
19 {
20 anim.SetTrigger(type.ToString());
21 }
22
23 private void Start()
24 {
25 anim = GetComponent<Animator>();
26 }
27
28 private void Update ()
29 {
30 anim.SetFloat("Speed", Speed);
31 }
32 }